﻿package org.leles.ui 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Bruno leles
	 */
	public dynamic class ButtonMovie extends MovieClip
	{
		protected var _action:Function;
		
		public function ButtonMovie() 
		{
			super();
			buttonMode = true;
		}
		
		public function get action():Function { return _action; }
		
		public function set action(value:Function):void 
		{
			if ( !(_action == null))
				addEventListener( MouseEvent.CLICK, doAction );
			if ( !Boolean(value) )
				removeEventListener(  MouseEvent.CLICK, doAction );
			
			_action = value;
		}
		
		private function doAction(e:MouseEvent):void 
		{
			_action();
		}
		
	}
	
}